/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package datas;

import Beans.Poke;
import Beans.User;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**

 @author Marie-Claude
 */
public interface PokesMapper {

  final String SELECT_POKE_FOR_USER = "select * from pokes where idPokedUser=#{idPokedUser}";
  final String SELECT_USER = "select username from user where idUser=#{senderID}";
  final String INSERT_POKE = "insert into pokes (idPokingUser, idPokedUser) values (#{idPokingUser}, #{idPokedUser})";
  final String DELETE_POKE = "delete from pokes where idPokedUser=#{idPokedUser} limit 5";

  @Select(SELECT_POKE_FOR_USER)
  @Results(value = {
    @Result(property = "idpokes", column = "idpokes"),
    @Result(property = "pokingUser", column = "idPokingUser", javaType = User.class, one = @One(select = "getUserById")),
    @Result(property = "idPokedUser", column = "idPokedUser"),})
  List<Poke> getAllByUserId(int idPokedUser);

  @Select(SELECT_USER)
  @Results(value = {
    @Result(property = "username", column = "username"),
    @Result(property = "userID", column = "idUser")})
  User getUserById(int senderID);

  @Insert(INSERT_POKE)
  void insert(Poke poke);

  @Delete(DELETE_POKE)
  void delete(int idPokingUser);
}
/*
 org.icefaces.ace.theme</param
 icesoft theme roller
 jquery themeroller 
 export in .jar 
 */
